// var el = document.getElementById("subNav")
// el.onmouseover = (e) => {
//     el.classList.add("active")

// }
// el.onmouseout = (e) => {
//     el.classList.remove("active")
// }

var btns = document.querySelectorAll(".header_nav li");
// console.log(btns)
var contents = document.querySelectorAll(".navMenu_list")
var navMenu = document.querySelector(".navMenu")
for (let i = 0; i < 7; i++) {
    // btns[i] : 每一个按钮元素;
    btns[i].onmouseenter = function() {
        reset();
        // console.log(navMenu);
        navMenu.classList.add("active");
        this.classList.add("active");
        var index = getIndex(this);
        //console.log(contents)
        contents[index].classList.add("active");
        //console.log(navMenu)
    }
    btns[i].onmouseleave = function() {
        reset();
    }
}

function reset() {
    for (let i = 0; i < btns.length - 2; i++) {
        navMenu.classList.remove("active");
        btns[i].classList.remove("active");
        //     console.log(contents[i]);
        contents[i].classList.remove("active");
    }
}

function getIndex(now) {
    for (var i = 0; i < btns.length; i++) {
        if (btns[i] === now) {
            return i;
        }
    }
}
//轮播图选项卡
var btn = document.querySelectorAll(".banner_nav li")
var bannerMenu = document.querySelectorAll(".bannerMenu")
var banner_item = document.querySelector(".banner_item")
    // console.log(btn)
    // console.log(bannerMenu)
    // console.log(banner_item)
for (let i = 0; i < btn.length; i++) {
    // btns[i] : 每一个按钮元素;
    btn[i].onmouseover = function() {

        reseta();


        //console.log(navMenu);

        banner_item.classList.add("active");
        this.classList.add("active");

        var index = getIndexa(this);

        //console.log(index)
        bannerMenu[index].classList.add("active");

    }
    btn[i].onmouseout = function() {
        reseta();
    }
}

function reseta() {
    for (let i = 0; i < btn.length; i++) {
        navMenu.classList.remove("active");
        btn[i].classList.remove("active");
        //     console.log(contents[i]);
        bannerMenu[i].classList.remove("active");
    }
}

function getIndexa(now) {
    for (var i = 0; i < btn.length; i++) {
        if (btn[i] === now) {
            //console.log(i)
            return i;

        }
    }
}
var container1 = new Swiper(".container1", {
    loop: true,
    autoplay: true,
    //effect : "cube",
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
    pagination: {
        el: '.swiper-pagination',
    }

});
var bullets = document.querySelectorAll("container1.pagination.bullets ")

for (var i = 0; i < bullets.length; i++) {
    bullets[i].onmouseover = function() {
        this.click();
    }
}
//第二个轮播图
new Swiper(".flash_auto", {
    loop: !1,
    slidesPerView: 4,
    slidesPerGroup: 4,
    spaceBetween: 14,
    loopFillGroupWithBlank: !1,
    loopPreventsSlide: !1,
    autoplay: !0,
    navigation: {
        nextEl: ".flash_rt",
        prevEl: ".flash_lt"
    }
});

function times() {

    var target = new Date('2021-06-19T10:56:00');
    var reduce = target.getTime() - Date.now();
    var shi = parseInt(reduce / 1000 / 60 / 60)
    var fen = parseInt(reduce / 1000 / 60 % 60)
    var miao = parseInt(reduce / 1000 % 60)
    if (reduce < 0) {
        return clearInterval(t)
    }
    shi = shi < 10 ? "0" + shi : shi
    fen = fen < 10 ? "0" + fen : fen
    miao = miao < 10 ? "0" + miao : miao
    console.log(shi, fen, miao)
    hour.innerHTML = shi
    minute.innerHTML = fen
    second.innerHTML = miao

}
var t = setInterval(times, 1000)
times()
    // 侧边栏
var b = document.querySelector(".right_nav");
b.addEventListener("mouseover",
        function(n) {
            n = (n = n || window.event).target || n.srcElement;
            "A" === n.nodeName && (n.children[0].children[0].classList.remove("active"), n.children[0].children[1].classList.add("active"))
        }),
    b.addEventListener("mouseout",
        function(n) {
            n = (n = n || window.event).target || n.srcElement;
            "A" === n.nodeName && (n.children[0].children[1].classList.remove("active"), n.children[0].children[0].classList.add("active"))
        }),
    b.addEventListener("click",
        function(n) {
            -1 != ((n = n || window.event).target || n.srcElement).className.indexOf("re") && document.documentElement.scrollTo({
                top: 0,
                behavior: "smooth"
            })
        }),
    document.addEventListener("scroll",
        function() {
            900 <= document.documentElement.scrollTop && b.children[5].classList.add("active"),
                document.documentElement.scrollTop < 900 && b.children[5].classList.remove("active")
        })